/**
 * Copyright (c) 2015-2030 by Beijing Yanlight Co., Ltd.
 * All rights reserved.
 */
package com.yanlight.app.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yanlight.app.request.LoginRequest;
import com.yanlight.app.request.ModifyPasswordRequest;
import com.yanlight.app.service.UserService;
import com.yanlight.support.http.Response;
import com.yanlight.util.ResponseUtil;

/**
 * @author haolw
 * @time 2017/08/18
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Response login(LoginRequest request) {
        return ResponseUtil.success(userService.login(request));
    }

    @PostMapping("/logout")
    public Response logout() {
        userService.logout();
        return ResponseUtil.success();
    }

    @PostMapping("/modifyPassword")
    public Response modify(ModifyPasswordRequest request) {
        userService.modifyPwd(request);
        return ResponseUtil.success();
    }

    @PostMapping("/detail")
    public Response detail() {
        return ResponseUtil.success(userService.getUserDetail());
    }
}
